<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ page import="java.util.*, cs5226.util.StringUtil" %>
<jsp:useBean id="threshold" class="cs5226.model.ThresholdBean" scope="page"/>
<%
	List thresholdsList = null;
	threshold=null;
	Map thresholdMap = StringUtil.getThresholdsMap();
	if(null!=request.getAttribute("thresholdsList"))
		thresholdsList = (List) request.getAttribute("thresholdsList");
%>

<h2>Threshold Configuration</h2>
	
<br/><br/><br/>

<style>

table
{
border-collapse:collapse;
}
table,th, td
{
border: 1px solid gray;
}
</style>


<form action='configthresholds-update'>

<table>
		<%
			if (request.getAttribute("msg") != null) {
		%>
		<tr><td colspan="6"><font color="red"><%=request.getAttribute("msg")%></font></td></tr>
		<%
			}
		%>
	<tr height="30">
		<td align="center" width="30%"><b>Metric Name</b></td>
		<td align="center"  width="20%"><b>Unit</b></td>
		<td align="center"  width="10%"><b>Min</b></td>
		<td align="center"  width="10%"><b>Not healthy</b></td>
		<td align="center"  width="20%"><b>Need DBA Attention</b></td>
		<td align="center"  width="10%"><b>Max</b></td>
	</tr>
	<%if(thresholdsList!=null && thresholdsList.size()>0){ 
		for(int i=0;i<thresholdsList.size();i++){
			threshold = (cs5226.model.ThresholdBean) thresholdsList.get(i);%>
			<tr><td><%=threshold.getParamName()%></td>
				<td><%=threshold.getParamUnit()%></td>
				<td><input name="<%=threshold.getParamID()%>_min" value="<%=threshold.getMin()%>"></td>
				<td><input name="<%=threshold.getParamID()%>_unhealthy" value="<%=threshold.getUnhealthy()%>"></td>
				<td><input name="<%=threshold.getParamID()%>_critical" value="<%=threshold.getCritical()%>"></td>
				<td><input name="<%=threshold.getParamID()%>_max" value="<%=threshold.getMax()%>"></td>
			</tr>
		<%}%>
		<tr height="30"><td align="center" colspan="6"> <input type="submit" class='button' value="Update"/> </td></tr>
	<%}else{%>
		<tr><td colspan="6">No Thresholds Available!.</td></tr>
	<%}%>
</table>
</form>

<script>
	$(function() {		
		$('.button').button();
	});
</script>